package com.jp.controller;

import com.jp.entity.Account;
import com.jp.service.AccountService;
import com.jp.service.OrderService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

//    @Autowired
//    private TestService testService;
//
//
//    @RequestMapping("/getDept")
//    public String getDept() {
//        return testService.getDept();
//    }

    @Autowired
    private OrderService orderService;

    @Autowired
    private AccountService accountService;

    @GlobalTransactional
    @PostMapping("/addOrder")
    public String addOrder(){
        accountService.save(new Account().setId(12L)
                .setResidue(1222).setTotal(192).setUsed(2113).setUserId(1233L));
        orderService.addOrder();
    return "addOrder";
    }
}
